package cn.jiyun.function.controller;

import cn.jiyun.Result.Result;
import cn.jiyun.function.service.CarService;
import cn.jiyun.pojo.function.Car;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/car")
@Slf4j
public class CarController {
    @Autowired
    private CarService carService;

    @PostMapping("/findPage")
    public Result findPage(@RequestParam(defaultValue = "1", name = "pageNum") Integer pageNum,
                           @RequestParam(defaultValue = "10", name = "pageSize") Integer pageSize,
                           @RequestBody Car car) {
        log.info("car: {}",car);
        return Result.ok(carService.findPage(pageNum, pageSize,car));
    }

    @GetMapping("/findCarById")
    public Result findCarById(Integer id) {
        Car car = carService.findCarById(id);
        return Result.ok(car);
    }

    @GetMapping("updateVerificationStatus")
    public Result updateVerificationStatus(Integer id, Integer status) {
        carService.updateVerificationStatus(id, status);
        return Result.ok();
    }

}
